package com.psychology.vo;

import lombok.Data;
import java.time.LocalDateTime;

@Data
public class AppointmentVO {
    private Long id; // 预约ID
    private String therapistName; // 咨询师姓名
    private String therapistTitle; // 咨询师职称
    private String therapistAvatar; // 咨询师头像
    private String date; // 预约日期 (格式：YYYY-MM-DD)
    private String time; // 预约时间段 (格式：HH:mm-HH:mm)
    private String type; // 咨询方式（在线咨询/面对面咨询）
    private String location; // 咨询地点
    private String status; // 预约状态 (pending/completed/cancelled)
    private String statusText; // 状态显示文本 (待进行/已完成/已取消)
    private LocalDateTime createTime; // 创建时间
    private LocalDateTime updateTime; // 更新时间

    // 从实体类转换为VO的静态方法
    public static AppointmentVO fromEntity(Appointment appointment) {
        AppointmentVO vo = new AppointmentVO();
        vo.setId(appointment.getId());
        vo.setTherapistName(appointment.getTherapist().getName());
        vo.setTherapistTitle(appointment.getTherapist().getTitle());
        vo.setTherapistAvatar(appointment.getTherapist().getAvatar());
        vo.setDate(appointment.getAppointmentDate().toString());
        vo.setTime(appointment.getTimeSlot());
        vo.setType(appointment.getType());
        vo.setLocation(appointment.getLocation());
        vo.setStatus(appointment.getStatus());
        vo.setStatusText(getStatusText(appointment.getStatus()));
        vo.setCreateTime(appointment.getCreateTime());
        vo.setUpdateTime(appointment.getUpdateTime());
        return vo;
    }

    // 获取状态显示文本
    private static String getStatusText(String status) {
        switch (status) {
            case "pending":
                return "待进行";
            case "completed":
                return "已完成";
            case "cancelled":
                return "已取消";
            default:
                return "未知状态";
        }
    }
}